﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LibMinecraft.Server;
using LibMinecraft.Model;

namespace PartyCraftServer.Commands
{
    public class ModeCommand : Command
    {
        public override bool RequiresOp
        {
            get { return true; }
        }

        public override string DefaultCommand
        {
            get { return "mode"; }
        }

        public override string Documentation
        {
            get { return "Changes the entire server's game mode.\nUsage: /mode [survival|creative|0|1]"; }
        }

        public override void ExecuteCommand(RemoteClient client, params string[] parameters)
        {
            if (parameters.Length != 1)
            {
                client.SendChat(ChatColor.Red + "Invalid parameters.  Use /mode [survival|creative|0|1]");
                return;
            }
            if (parameters[0].ToLower() != "survival" && parameters[0].ToLower() != "creative" &&
                parameters[0].ToLower() != "0" && parameters[0].ToLower() != "1")
            {
                client.SendChat(ChatColor.Red + "Invalid parameters.  Use /mode [survival|creative|0|1]");
                return;
            }
            bool creative = parameters[0].ToLower() == "creative" || parameters[0].ToLower() == "1";
            PartyCraft.Server.ChangeServerMode(creative ? GameMode.Creative : GameMode.Survival);
        }
    }
}
